﻿<%--
  Created by IntelliJ IDEA.
  User: shen
  Date: 2020/3/13
  Time: 23:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
    <base href="${basePath}"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>查看未处理反馈</title>
    <link rel="icon"  href="../../images/favicon.ico" type="image/x-icon" />
    <link rel="bookmark" href="images/favicon.ico" type="image/x-icon"/>
    <%@include file="../common_resource.jsp" %>
    <link href="font-awesome/css/font-awesome.css" rel="stylesheet">

    <link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <style type="text/css">
        .msg{
            color: red;
            font-style: italic;
            font-weight: normal;
        }
        .listData_btn{
            font-size: 11px;
            margin:0px;
        }
    </style>
    <style>
        .main_body{
            font-size: 15px;
        }
    </style>
    <script>
        function to(){
            location.href="views/user/user_input.jsp";
        }
    </script>


</head>

<body class="main_body">
<div class="container container-1180" >
    <div class="col" style="margin-top: 10px;">
        <div class="panel panel-info">
            <div class="panel-heading">
                <span ><i class="fa fa-user"></i></span> <label><font style="font-weight: bold;margin-left: 10px;font-size: 18px">学&nbsp;生&nbsp;信&nbsp;息</font></label>
                <label style="float: right;">
                    <div class="button_bar">
                        <button class="btn btn-info btn-sm" onclick="to();">继续新增</button>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    </div>
                </label>
            </div>

            <div class="panel panel-warning" style="margin-top: -40px;margin: 10px">
                <div class="panel-heading">
                    <h3 class="panel-title"><span class="glyphicon glyphicon-th-list"></span>&nbsp;所有学生账号信息</h3>
                </div>

                <div class="panel-body">
                    <table class="table table-hover" style="margin-left:190px; font-size: 16px;width: 680px; text-align: center;">
                        <tr style="height: 25px; font-weight: bold;" class="success">
                            <th align="center" width="60px" style="text-align: center;">序号</th>
                            <th align="center" style="text-align: center;">学生学号</th>
                            <th align="center" style="text-align: center;">学生姓名</th>
                            <th align="center" style="text-align: center;">登录密码</th>
                            <th align="center" width="160px" style="text-align: center;">操作</th>
                        </tr>

                        <c:forEach var="user" items="${sessionScope.selectStudent}" varStatus="status" >


                            <tr id="row${user.sstsUserID}">
                                <td align="center">${status.count}</td>
                                <td>
                                    <span id="name${user.sstsUserID }" style="display: block;">${user.sstsNo}</span>
                                    <div id="update${user.sstsUserID }" style="display: none">
                                    </div>
                                </td>
                                <td>
                                    <span id="name${user.sstsUserID }" style="display: block;">${user.username}</span>
                                </td>
                                    <%--  <td>
                                          <span id="name${sstsFeedbackNot.sstsFeedbackID }" style="display: block;">${sstsFeedbackNot.feedbackStatus}</span>
                                      </td>--%>
                                <td>
                                    <span id="name${user.sstsUserID }" style="display: block;">${user.password}</span>
                                </td>
                                <td>
                                     <span style="margin-left:20px;">
                                             <input type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#doUpdateStu" data-backdrop="static" value="更新" onclick="doUpdate('${user.sstsUserID}','${user.username}');"></input>
                                             <input type="button" class="del btn btn-danger btn-sm" value="删除" sstsUserID="${user.sstsUserID}" username="${user.username}" style="margin-right:20px;"></input>
                                     </span>
                                  <%--  <a class="btn btn-info btn-sm" data-toggle="modal" data-target="#doUpdateSQ" data-backdrop="static" value="更新" onclick="doUpdate(${user.sstsUserID});">
                                        <span class="glyphicon glyphicon-refresh"></span> 更新
                                    </a>
                                    <a  class="del btn btn-danger btn-sm" sstsUserID="${user.sstsUserID}">
                                        <span class="glyphicon glyphicon-trash" ></span> 删除
                                    </a>--%>
                                </td>

                            </tr>
                        </c:forEach>

                    </table>
                    <div class="pager" style="padding-left:50px;background-color: #FAEBD7">
                        <%--分页显示--%>
                        总${sessionScope.selectStudent.getTotal()}条 &nbsp;&nbsp; 第${sessionScope.selectStudent.getPageNum()}页/共${sessionScope.selectStudent.getPages()}页
                        &nbsp;&nbsp; &nbsp;&nbsp;
                        <c:if test="${sessionScope.selectStudent.getPageNum() gt 1}">
                            <a href="users/selectStudent/1">第一页</a> &nbsp;
                        </c:if>
                        <c:if test="${sessionScope.selectStudent.getPageNum() gt 1}">
                            <a href="users/selectStudent/${sessionScope.selectStudent.getPageNum()-1}">上一页</a>&nbsp;
                        </c:if>

                        <c:if test="${sessionScope.selectStudent.getPageNum() lt sessionScope.selectStudent.getPages()}">
                            <a href="users/selectStudent/${sessionScope.selectStudent.getPageNum()+1}">下一页</a>&nbsp;
                        </c:if>
                        <c:if test="${sessionScope.selectStudent.getPageNum() lt sessionScope.selectStudent.getPages()}">
                            <a href="users/selectStudent/${sessionScope.selectStudent.getPages()}">末页</a>&nbsp;
                        </c:if>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<%--更新操作的模态框--%>
<div class="modal fade" tabindex="-1" role="dialog" id="doUpdateStu">
    <div class="modal-dialog" role="document">
        <div class="modal-content">

        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script src="bootstrap/plugins/transition.js"></script>
<script src="bootstrap/plugins/modal.js"></script>
<script src="bootstrap/plugins/tooltip.js"></script>
<script src="bootstrap/plugins/popover.js"></script>
<script src="bootstrap/plugins/collapse.js"></script>
<script src="bootstrap/js/jquery.editable-select.min.js"></script>
<script src="js/jquery-2.0.0.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
<!-- Mainly scripts -->
<script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="js/plugins/slimscroll/jquery.slimscroll.min.js"></script>

<!-- Custom and plugin javascript -->
<script src="js/inspinia.js"></script>
<script src="js/plugins/pace/pace.min.js"></script>

<!-- Sweet alert -->
<script src="js/plugins/sweetalert/sweetalert.min.js"></script>


<!-- JavaScript Test -->
<script type="text/javascript">

    // 将表单加入到模态框中显示，查询显示需要更新的数据
    function doUpdate(sstsUserID) {

        // 在加入表单到模态框前先清除模态框内之前的表单
        $('#doUpdateStu .modal-content').empty();

        $.get('users/selectStudentById',{sstsUserID: sstsUserID},function (res) {
            console.log(res);
            $('#doUpdateStu .modal-content').append(res);
            console.log(123);

        })
    }


    // 更新保存
    function updateSave(sstsUserID,username) {
        //console.log("123");
        // 序列化表单，将表单输入框的值封装成：empno=7369&ename=SMITH&job=CLERK&job=7902&hiredate=1980-12-17&sal=5900.0&comm=100.0&deptno=20
        var data = $('#updateStudent').serialize();
        console.log(data);
        $.post('users/updateStudent',data,function (res) {
            if (res.updateStudent){
                // 手动关闭模态框
                console.log(res.updateStudent);
                $('#doUpdateSQ').modal('hide');
                $('#doUpdateSQ .modal-content').empty();
                console.log(res.updateStudent);
                swal({
                    title: "更新学生账号信息",
                    text: "更新"+sstsUserID+"的学生账号信息成功",
                    type: "success"
                },function () {
                    location.href="users/selectStudent/1";
                });

            } else {
                swal({
                    title: "更新学生账号信息",
                    text: "更新"+username+"的学生账号信息失败，请重新检查",
                    type:"error"
                });
            }
        },'json')

    }

    // 删除弹出框
    $('.del').click(function () {

        // 获取属性值
        var sstsUserID=$(this).attr('sstsUserID');
        var username=$(this).attr('username');

        swal({
                title: "你确定删除"+username+"的学生账号信息?",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "是的，删除它！",
                cancelButtonText: "取消",
                closeOnConfirm: false,
                closeOnCancel: false },
            function (isConfirm) {
                if (isConfirm) {
                    // 通过get发送信息到doDelete
                    $.get('users/deleteStudent',{sstsUserID:sstsUserID},
                        function (res) {
                            if (res.deleteStudent){
                                //console.log(res.result);
                                $('#row'+sstsUserID).remove();
                                swal("删除", "该学生"+username+"的信息已经被删除", "success");
                            }else{
                                swal("警告", "该学生"+username+"的信息不能被删除", "error");
                            }
                        },'json')

                } else {
                    swal("取消", "该学生"+username+"的信息删除操作被取消)", "error");
                }
            });
    });

</script>
</body>
</html>
